package com.lanchetech.dao;

import com.lanchetech.bean.request.*;
import com.lanchetech.bean.response.GoodSpuListResp;
import com.lanchetech.bean.response.SpuResp;
import com.lanchetech.bean.vo.*;
import com.lanchetech.entity.Merchant;
import com.lanchetech.entity.Sku;
import com.lanchetech.entity.Spu;
import com.lanchetech.entity.User;
import org.apache.ibatis.annotations.Mapper;import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.List;

@Mapper
public interface SpuMapper {
    int deleteByPrimaryKey(Long id);

    int insert(Spu record);

    int insertSelective(Spu record);

    Spu selectByPrimaryKey(Long id);

    Sku selectById(Long id);

    int updateByPrimaryKeySelective(Spu record);

    int updateByPrimaryKey(Spu record);

    int insert2(Spu record);

    List<SpuResp> findAllAdminPage(SpuReq req);

    /**
     * 面向用户的商品分页
     *
     * @return
     */
    List<SpuResp> findAllPublicPage(SpuPageReq req);

    List<ShopSpuVO> findShopSpuPage(SpuPageReq req);

    List<Spu> findAllByIds(@Param("ids") List<Long> ids);

    List<Spu> findAllLikeSpu(@Param("categoryId") Long categoryId);

    int updateSalesById(@Param("count") Integer count, @Param("id") Long id);

    int subOneSalesById(@Param("id") Long id);

    int subSalesById(@Param("count") Integer count, @Param("id") Long id);

    int updateDeletedById(@Param("updatedDeleted") Byte updatedDeleted, @Param("id") Long id);

    Spu findOneByShopIdAndTypeAndHiddenOrderBySortsDesc(@Param("shopId") Long shopId, @Param("type") Byte type, @Param("hidden") Byte hidden);

    int updateFiveStarById(@Param("updatedFiveStar") Integer updatedFiveStar, @Param("id") Long id);

    int updateSortsById(@Param("updatedSorts") Integer updatedSorts, @Param("id") Long id);

    int updateHiddenById(@Param("updatedHidden") Byte updatedHidden, @Param("id") Long id);

    Long countByTenantId(@Param("tenantId") Long tenantId);

    List<Spu> findAllByHiddenAndDeleted(@Param("hidden") Byte hidden, @Param("deleted") Byte deleted);

    List<Spu> findAllByCategoryId(@Param("categoryId") Long categoryId);

    List<StatisticsCountVO> countLikeSearch(String search);

    List<StatisticsCountVO> getTotalWordCount();

    List<StatisticsCountVO> getItemCount();

    List<StatisticsCountVO> getDisplayCount(@Param("search") String search);

    StatisticsCountVO getTotalWordCountByCategoryId(@Param("categoryId") Long categoryId);

    StatisticsCountVO getItemCountByCategoryId(@Param("categoryId") Long categoryId);

    int batchOffline(@Param("list") List<Long> spuIds, @Param("hidden") Byte hidden);

    int resetSorts(@Param("startNum") Long startNum, @Param("endNum") Long endNum);

    List<StatisticsCountVO> getTotalWordCountByCategoryIds(@Param("list") List<Long> categoryIds);

    List<StatisticsCountVO> getItemCountByCategoryIds(@Param("list") List<Long> categoryIds);

    int updateHiddenByTenantId(@Param("updatedHidden") Byte updatedHidden, @Param("tenantId") Long tenantId);

    Long countByHiddenAndShopId(@Param("hidden") Byte hidden, @Param("shopId") Long shopId, @Param("req") SpuReq req);

    Long countByHiddenInAndShopId(@Param("list") List<Byte> list, @Param("shopId") Long shopId, @Param("req") SpuReq req);

    int updateImageListById(@Param("updatedImageList") String updatedImageList, @Param("id") Long id);

    int updateVideoById(@Param("updatedVideo") String updatedVideo, @Param("id") Long id);

    int updateContentById(@Param("updatedContent") String updatedContent, @Param("id") Long id);

    int updateAuditStatusAndAuditMessageById(@Param("updatedAuditStatus") Byte updatedAuditStatus, @Param("updatedAuditMessage") String updatedAuditMessage, @Param("id") Long id);

    Long countByParam(SpuReq req);

    Long countByAuditStatusAndParam(@Param("auditStatus") Byte auditStatus, @Param("req") SpuReq req);

    List<SpuVO> findTopSpu();

    int batchUpdateShopCategory(List<EditSpuShopCategoryReq> req);

    List<BossRankingVo> getBossRanking(PageReq req);

    Spu findOneBySpuId(Long spuId);

    BigDecimal getMinPrice(Long id);

    SpuItemVO getSpuById(Long spuId);

    void preferredImage(@Param("spuId") Long spuId,@Param("main") boolean main);

    List<SpuResp> likeSpu(SpuPageReq req);

    /**
     * 全球好物一级分类
     * @param
     * @return
     */
    List<GoodSpuListResp> GoodSpuList(GoodSpuListReq goodSpuListReq);

    List<Spu> lotterySpuList(LotterySpuListReq lotterySpuListReq);

    ShopPrizeVo shopPrize(Long spuId);

    String getShopImg(Long prizeId);

    User addAgency(User user);

    List<Merchant> getMerchant(long id);
}